package com.example.dormitorymanagement.repository;

import com.example.dormitorymanagement.model.Building;
import com.example.dormitorymanagement.model.Room;
import com.example.dormitorymanagement.model.Room.RoomStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RoomRepository extends JpaRepository<Room, Integer> {

    // 根据宿舍楼查询房间
    List<Room> findByBuilding(Building building);

    // 根据宿舍楼ID和房间状态查询房间
    List<Room> findByBuildingIdAndStatus(Integer buildingId, RoomStatus status);

    // 根据号和宿舍楼查询房间
    Room findByRoomNumberAndBuilding(String roomNumber, Building building);

    // 统计宿舍楼中的可用数量
    long countByBuildingAndStatus(Building building, RoomStatus status);

    boolean existsByRoomNumberAndBuilding(String roomNumber, Building building);
}
